/******************************************************************************
*
*               Copyright Mentor Graphics Corporation 2003
*                           All rights reserved
*
*   THIS WORK CONTAINS TRADE SECRETS AND PROPRIETARY INFORMATION WHICH IS
*    THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS
*                        SUBJECT TO LICENSE TERMS
*
*******************************************************************************

*******************************************************************************
* FILE NAME                                                          VERSION
* act_struct_declaration_test.c                                        1.1
*
* COMPONENT
* ANSI/ISO C test application
*
* DESCRIPTION
* Demonstrates different definition- and usage-methods of structs
*
* DATA STRUCTURES
* struct regular_struct                         Anonymous struct
* typedef struct typedef_anonymous_struct       Typedef anonymous struct
* struct typedef_struct                         Named typedef struct
* struct typedef_struct_with_ref                Typedef struct
* struct oneAddressStruct                       See below
* struct twoAddressStruct                        - " -
* struct threeAddressStruct                      - " -
* struct fourAddressStruct                       - " -
*
* FUNCTIONS
* int act_struct_declaration_test(int value)
*
* DEPENDENCIES
* act_test.h
******************************************************************************/


#include "act_test.h"

#if (ACT_STRUCT_DECLARATION_TEST)

struct regular_struct
{
     int     a;
     double  b;
};

typedef struct
{
     int     a;
     double  b;
} typedef_anonymous_struct;



struct typedef_struct
{
     int     a;
     double  b;
};
typedef struct typedef_struct TypedefedStruct;

/*  ********************************************* */
struct oneAddressStruct
{
     void*  addr0;
};

struct twoAddressStruct
{
     void*  addr0;
	 void*  addr1;
};

struct threeAddressStruct
{
	 void*  addr0;
	 void*  addr1;
	 void*  addr2;
};

struct fourAddressStruct
{
	 void*  addr0;
	 void*  addr1;
	 void*  addr2;
	 void*  addr3;
};

struct oneAddressStruct     g_oneAddressStruct;
struct twoAddressStruct     g_twoAddressStruct;
struct threeAddressStruct   g_threeAddressStruct;
struct fourAddressStruct    g_fourAddressStruct;

/******************************************************************************
* FUNCTION
* int act_struct_declaration_test(int value)
*
* DESCRIPTION
* Demonstrates the use and declaration of different types of structs
* Including regular and anonymous structs and structs used with
* typedef keyword
*
* INPUTS
* int value                     Counter value from ansi_c_test(..) in act.c
*
* OUTPUTS
* int                           Computed value from structs
******************************************************************************/
int act_struct_declaration_test(int value)
{
     int value1;

     struct regular_struct           regularstruct;

     typedef_anonymous_struct        typedefanonymousstruct;
     TypedefedStruct                 typedefstructwithdecl;


     regularstruct.a = 1;
     regularstruct.a = 2;
     regularstruct.a = 3;
     regularstruct.b = 1.2222;

     typedefanonymousstruct.a = 1;
     typedefanonymousstruct.a = 2;
     typedefanonymousstruct.a = 3;
     typedefanonymousstruct.b = 11.222;

     typedefstructwithdecl.a = 1;
     typedefstructwithdecl.a = 2;
     typedefstructwithdecl.a = 3;
     typedefstructwithdecl.b = 111.22;

     value1 = sizeof(g_oneAddressStruct);
     value += value1;

     value1 = sizeof(g_twoAddressStruct);
     value += value1;

     value1 = sizeof(g_threeAddressStruct);
     value += value1;

     value1 = sizeof(g_fourAddressStruct);
     value += value1;

     return( typedefanonymousstruct.a  +
             typedefstructwithdecl.a   +
             regularstruct.a           +
             value
           );
}

#endif
